package com.mapreduce.flowcomparablepartition;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class FlowCountMapper extends Mapper<LongWritable, Text, FlowBean, Text> {
    FlowBean k = new FlowBean();
    Text v = new Text();

    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        //读取一行
        String line = value.toString();
        String[] data = line.split("\t");
        String phoneNo=data[0];
        v.set(phoneNo);
        k.setUpFlow(Long.parseLong(data[1]));
        k.setDownFlow(Long.parseLong(data[2]));
        k.setSumFlow(Long.parseLong(data[3]));
        context.write(k,v);
    }
}
